<template>
	
	<view>
	 		<!-- 自定义导航栏 -->
	 		<view class="navBarBox">
	 			<!-- 状态栏占位 -->
	 			<view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
	 			<!-- 真正的导航栏内容 -->
	 			<view class="navBar">
	 				<view class="goback">
	 					<view @click="goBack" class="goicon"style="background:url(../../static/goback.png);background-size:contain;background-repeat: no-repeat;">			
	 					</view>
	 				</view>
	 				<view class="title">班级管理</view>
	 				<view class="right">
	 					
	 				</view>
	 			</view>
	 		</view>
	 		<!-- 页面内容 -->
			<view class="zong" v-for="(v,i) in data1">
				<!-- 06班级管理 -->
				<view class="content1">
					<view class="content1-img">
						
					</view>
					<view class="content1-2">
						<text>{{v.mclass.className | upper}} | {{v.teacher.teacherName}}</text>
						<text>{{v.mclass.className | yuzhou}}入学</text>
					</view>
					<view class="content1-3">
						<!-- <button type="primary" > -->
							
							<navigator 
							:url="'./classmanagAdd?item='+ encodeURIComponent(JSON.stringify(v.mclass))">
							<button type="primary" >编辑</button>
							</navigator>
						<!-- </button> -->
						
					</view>
				</view>
				
				<!-- <view class="content1">
					<view class="content1-img">
						
					</view>
					<view class="content1-2">
						<text>一年级3班 | 李老师</text>
						<text>2019级入学</text>
					</view>
					<view class="content1-3">
						<button type="primary" @click="bianji">编辑</button>
					</view>
				</view> -->
				
				<!-- <view class="content1">
					<view class="content1-img">
						
					</view>
					<view class="content1-2">
						<text>一年级3班 | 李老师</text>
						<text>2019级入学</text>
					</view>
					<view class="content1-3">
						<button type="primary" @click="bianji">编辑</button>
					</view>
				</view> -->
				
				<!-- <view class="content1">
					<view class="content1-img">
						
					</view>
					<view class="content1-2">
						<text>一年级3班 | 李老师</text>
						<text>2019级入学</text>
					</view>
					<view class="content1-3">
							<button type="primary" @click="bianji">编辑</button>
					</view>
				</view> -->
			</view>
	 	</view>
	
	
</template>



<style>
	*{
		padding:0;
		margin:0
	}
	body{
		background: #e8e8ee;
	}
	
	 .navBarBox {}
	 
	 	.navBarBox .statusBar {}
	 
	 	.navBarBox .navBar {
	 		padding: 3rpx 50rpx;
	 		padding-bottom: 8rpx;
	 		display: flex;
	 		justify-content: space-between;
	 
	 		line-height: 93rpx;
	 		font-size: 40rpx;
	 	}
	 
	 	.goback {
	 		flex: 1;
	 		height: 100%;
	 	}
	 	.goicon{
	 		width: 30rpx;
	 		height: 30rpx;
	 		background-color: #00BEA9;
	 		margin-top: 30rpx;
	 	}
	 	.title {
	 		flex: 1;
	 		height: 100%;
	 		
	 	}
	 	.right{
	 		flex: 1;
	 	}
	
	.zong{
		/* display: flex; */
		padding: 20rpx;
	}
	.content1{
		display: flex;
		align-items: center;
		margin-top: 20rpx;
		padding-left:30rpx;
		/* width: 692rpx; */
		height: 218rpx;
		background: #FFFFFF;
		box-shadow: #c8c8c8 2rpx 2rpx 2rpx 0;
	}
	.content1:first-child{
		margin-top: 0;
	}
	.content1-img{
		width: 116rpx;
		height:126rpx;
		 background-image: linear-gradient(salmon, yellow);
	}
	.content1-2{
		display: flex;
		flex-direction: column;
		margin-left: 35rpx;
		width: 354rpx;
	}
	.content1-2 text:first-child{
		font-size: 32rpx;
	}
	.content1-2 text:nth-child(2){
		margin-top: 26rpx;
		font-size: 28rpx;
	}
	.content1-3>navigator>button{
		width: 120rpx;
		height: 60rpx;	
		font-size: 30rpx;
		text-align: center;
		line-height: 60rpx;
	}
	.content1-3{
		margin-right: 14rpx;
	}
</style>
<script>
	export default {
		data() {
			return {
				Data:{
					orgId:null
				},
				// 状态栏高度
				statusBarHeight: 0,
				// 导航栏高度
				navBarHeight: 82+11,
				
				// 页面数据
				data1:[],
			}
		},
		methods: {
			// 返回上一级
			goBack(){
				// 此处是写返回页面的方法、
							
				uni.navigateBack({
				    delta: 1//返回只上一级页面
				});
			},
			bianji(v){
				// uni.navigateTo({
					// url:'./classmanagAdd',
					// events: {
					// 	// 为指定事件添加一个监听器，获取被打开页面传送到当前页面的数据
					// 	acceptDataFromOpenedPage: function(data) {
					// 		console.log(data)
					// 	},
					// 	someEvent: function(data) {
					// 		console.log(data)
					// 	}
					// },
					// success: function(res) {
					// 	console.log("res",res);
					//     // 通过eventChannel向被打开页面传送数据
					//     res.eventChannel.emit('acceptDataFromOpenerPage', {data:v})
					//   // 就这里
					//   }
				// })
			},
			
			
		},
		//第一次加载时调用
		created() {
			//获取手机状态栏高度
			this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
			// 获取学校数据
			// this.Data=uni.getStorageSync('schAdminConfirmData')
			if(uni.getStorageSync('schAdminConfirmData')){
				let Data1=uni.getStorageSync('schAdminConfirmData')
				this.Data.orgId=Data1.orgId
				console.log('学校id',this.Data.orgId)
			}else{
				this.Data.orgId=1;
				console.log('学校id',this.Data.orgId)
			}
		},
		// 过滤器
		filters: {
		    upper: function(val) {
		        // return val.charAt(0).toUpperCase() + val.slice(1);
				
				let jiequ=val.slice(0,4)
				switch(jiequ){
					case '2017':
						jiequ='五年级';
						break;
					case '2018':
						jiequ='四年级';
						break;
					case '2019':
						jiequ='三年级';
						break;
					case '2020':
						jiequ='二年级';
						break;
					case '2021':
						jiequ='一年级';
						break;
					case '2016':
						jiequ='六三年级';
						break;
				}
				return jiequ
		    },
			yuzhou:function(val){
				return val.slice(0,5)
				
			}
		},
		onLoad() {
			this.$myRequest({
			    url:`/admin/mclass/find/${this.Data.orgId}`, //仅为示例，并非真实接口地址。
			    // data: {
			    //     // id:1
			    // },
			    header: {
			         //自定义请求头信息
			    },
			    success: (res) => {
			        console.log('成功1',res.data.data);
					// for(let i=0;i<res.data.data.length;i++){
					// 	console.log(res.data.data[i].teacher)
					// 	this.data1=res.data.data[i]
					// 	console.log(55555,this.data1)
					// }
					this.data1=res.data.data
					console.log(55555,this.data1)
					// this.data=res.data.data.teacher
			        
			    },
				fail:(err)=>{
					console.log('失败',err)
				}
			});
		}
	}
</script>